home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / tex / bin / maketexpk < prev    next >
Text File  |  1993-09-06  |  4KB  |  163 lines

  1. #!/bin/sh
  2. #
  3. #  Do not run this script, or dvips, as setuid programs!  This will
  4. #  result in a major security hole!
  5. #
  6. #   This script file makes a new TeX PK font, because one wasn't
  7. #   found.  Parameters are:
  8. #
  9. #   name dpi bdpi magnification [mode [subdir]]
  10. #
  11. #   `name' is the name of the font, such as `cmr10'.  `dpi' is
  12. #   the resolution the font is needed at.  `bdpi' is the base
  13. #   resolution, useful for figuring out the mode to make the font
  14. #   in.  `magnification' is a string to pass to MF as the
  15. #   magnification.  `mode', if supplied, is the mode to use.
  16. #
  17. #   Note that this file must execute Metafont, and then gftopk,
  18. #   and place the result in the correct location for the PostScript
  19. #   driver to find it subsequently.  If this doesn't work, it will
  20. #   be evident because MF will be invoked over and over again.
  21. #
  22. #   Of course, it needs to be set up for your site.
  23. #
  24. TEXDIR=/usr/lib/tex
  25. LOCALDIR=/LocalLibrary/Fonts/TeXFonts
  26. DESTDIR=$LOCALDIR/pk
  27. #
  28. # TEMPDIR needs to be unique for each process because of the possibility
  29. # of simultaneous processes running this script.
  30. #
  31. if test "$TMPDIR" = ""
  32. then
  33.    TEMPDIR=/tmp/mtpk.$$
  34. else
  35.    TEMPDIR=$TMPDIR/mtpk.$$
  36. fi
  37. NAME=$1
  38. DPI=$2
  39. BDPI=$3
  40. MAG=$4
  41. MODE=$5
  42. #
  43. #   Prevent display under the X Window System.  Except it doesn't always
  44. #   work; some sh'ells don't seem to understand unset.  There are also some
  45. #   versions of METAFONT that don't work if the DISPLAY isn't set and
  46. #   the term type is set to xterm.
  47. #
  48. # unset DISPLAY
  49. umask 0
  50.  
  51. if test "$MODE" = ""
  52. then
  53.    if test $BDPI = 300
  54.    then
  55.       MODE=imagen
  56.    elif test $BDPI = 200
  57.    then
  58.       MODE=FAX
  59.    elif test $BDPI = 360
  60.    then
  61.       MODE=nextII
  62.    elif test $BDPI = 400
  63.    then
  64.       MODE=nexthi
  65.    elif test $BDPI = 100
  66.    then
  67.       MODE=nextscreen
  68.    elif test $BDPI = 72
  69.    then
  70.       MODE=seventwo
  71.    elif test $BDPI = 635
  72.    then
  73.       MODE=linolo
  74.    elif test $BDPI = 1270
  75.    then
  76.       MODE=linohi
  77.    elif test $BDPI = 2540
  78.    then
  79.       MODE=linosuper
  80.    else
  81.       echo "I don't know the mode for $BDPI"
  82.       echo "Have your system admin update MakeTeXPK"
  83.       exit 1
  84.    fi
  85. fi
  86.  
  87. #  Something like the following is useful at some sites.
  88. # DESTDIR=/usr/local/lib/tex/fonts/pk.$MODE
  89. GFNAME=$NAME.$DPI'gf'
  90. PKNAME=$NAME.$DPI'pk'
  91.  
  92. # Clean up on normal or abnormal exit
  93. trap "cd /; rm -rf $TEMPDIR $DESTDIR/pktmp.$$" 0 1 2 15
  94.  
  95.  
  96. if test ! -d $DESTDIR
  97. then
  98.    mkdir $DESTDIR
  99.    chmod 777 $DESTDIR
  100. fi
  101.  
  102. if test "$6" != ""
  103. then
  104.    DESTDIR=$DESTDIR"$6"
  105.    if test ! -d $DESTDIR
  106.    then
  107.       mkdir $DESTDIR
  108.       chmod 777 $DESTDIR
  109.    fi
  110. fi
  111.  
  112. # added by gwb, to allow searching in current dir before cd'ing
  113. if test "$MFINPUTS" != ""
  114. then
  115.    MFINPUTS=$MFINPUTS:`pwd`; export MFINPUTS
  116. fi
  117. mkdir $TEMPDIR
  118. cd $TEMPDIR
  119.  
  120. if test -r $DESTDIR/$PKNAME
  121. then
  122.    echo "$DESTDIR/$PKNAME already exists!"
  123.    exit 0
  124. fi
  125.  
  126. # check also in the standard place
  127.  
  128. if test "$6" = ""
  129. then
  130.    if test -r $TEXDIR/fonts/pk/$PKNAME
  131.    then
  132.       echo $TEXDIR/fonts/pk/$PKNAME already exists!
  133.       exit 0
  134.    fi
  135. else
  136.    if test -r $TEXDIR/fonts/pk/$6"$PKNAME"
  137.    then
  138.       echo $TEXDIR/fonts/pk/$6"$PKNAME" already exists!
  139.       exit 0
  140.    fi
  141. fi
  142.  
  143. unset DISPLAY
  144. echo "mf \"\\mode:=$MODE; mag:=$MAG; scrollmode; input $NAME\" </dev/null"
  145. mf "\mode:=$MODE; mag:=$MAG; scrollmode; input $NAME" </dev/null
  146. if test ! -r $GFNAME
  147. then
  148.    echo "Metafont failed for some reason on $GFNAME"
  149.    exit 1
  150. fi
  151.  
  152. gftopk -v ./$GFNAME ./$PKNAME
  153.  
  154. # Install the PK file carefully, since others may be doing the same
  155. # as us simultaneously.
  156.  
  157. mv $PKNAME $DESTDIR/pktmp.$$
  158. cd $DESTDIR
  159. mv pktmp.$$ $PKNAME
  160. chmod a+r $PKNAME
  161.  
  162. exit 0
  163.